﻿using Common;
using Common.Dtos;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sigma.Admin.Client.Services
{
    public class MenuService : IMenuService
    {
        private readonly HttpRestClient _client;
        private readonly string serviceName = "Menu";

        public MenuService(HttpRestClient client)
        {
            _client = client;
        }
        public async Task<ApiResponse<List<MenuDto>>> GetMenu()
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.GET;
            request.Route = $"api/{serviceName}/GetMenu";
            var res = await _client.ExecuteAsync<List<MenuDto>>(request);
            
            return res;
        }

        public async Task<ApiResponse> AddMenu(MenuDto menuDto)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.POST;
            request.Route = $"api/{serviceName}/AddMenu";
            request.Parameter = menuDto;
            var res = await _client.ExecuteAsync(request);

            return res;
        }

        public async Task<ApiResponse> DeleteMenu(int id)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.DELETE;
            request.Route = $"api/{serviceName}/DeleteMenu?id={id}";
            var res = await _client.ExecuteAsync(request);

            return res;
        }
    }
}
